找传奇、传世资源到传世资源站!

delphi7进行摄像头的开启、拍照、录像功能

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

使用delphi7开发的拍照、录像功能from clipboard//开启摄像头
procedure TForm1.Button1Click(Sender: TObject);
var
  index: integer;
begin
  index := Combobox1.Items.IndexOf(Combobox1.Text);
  hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,
    Panel1.Left,Panel1.Top,Panel1.Width,Panel1.Height,self.Handle,index);
  //hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,
   // Panel1.Left,Panel1.Top,Panel1.Width,Panel1.Height,self.Handle,0);
  if hWndC <> 0 then
  begin
    SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
    SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
    SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
    SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
    SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
    SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
  end;
end;
//拍照保存图片
procedure TForm1.Button3Click(Sender: TObject);
var  fileName: string;
begin
  if not DirectoryExists('C:\\imgTemp') then //判断目录是否存在
  try
    begin
      ForceDirectories('C:\\imgTemp');  // 创建目录
    end;
  finally
    raise Exception.Create('创建目录失败!');
  end;

  fileName := 'C:\\imgTemp\\test.jpg';
  if hWndC <> 0 then begin
    if FileExists(pchar(fileName)) then
    begin
      DeleteFile(pchar(fileName));
    end;
    SendMessage(hWndC,WM_CAP_SAVEDIB,0,Longint(pchar(fileName)));
    ShowMessage('保存图片成功!');
  end
  else begin
    ShowMessage('请先开启摄像头!');
  end;
end;

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复